home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / envdate.zip / ENVDATE.ASM < prev    next >
Assembly Source File  |  1987-09-17  |  2KB  |  96 lines

  1. ;----------------------------------------------------------------
  2. ; This function will set the Environment variable ENVDATE
  3. ; to be the current date. This is useful for entering the
  4. ; date of comilation into a program, which could then be done
  5. ; with a command line define and a small .BAT file.
  6. ;----------------------------------------------------------------
  7.  
  8. cseg    segment
  9.  
  10.     org    0100h
  11.  
  12.     assume    cs:cseg,ds:nothing
  13.  
  14. main    proc    far
  15.     jmp    begin
  16.  
  17.     db    5 dup ('STACK   ')
  18. stack        label    word
  19.  
  20. stkseg        dw    ?
  21. stkptr        dw    ?
  22.  
  23. outlen        db    len_out_str
  24.  
  25. out_str     db    'SET CURDATE='
  26. month        db    'mm'
  27.         db    '/'
  28. day        db    'dd'
  29.         db    '/'
  30. year        db    'yy'
  31.         db    0dh
  32. len_out_str    equ    $-out_str
  33.  
  34. begin:
  35.     mov    sp,offset stack
  36.  
  37.     mov    ax,cs
  38.     mov    ds,ax            ; get addressability
  39.  
  40.     mov    bx,offset end_of_code    ; how much code and data?
  41.     mov    cl,4            ; it's in paragraps
  42.     shr    bx,cl
  43.     inc    bx            ; throw one more in for good measure
  44.     mov    ah,04ah         ; reallocate memory
  45.     int    21h            ; and do it
  46.  
  47.     mov    ah,02ah         ; get date
  48.     int    21h            ; and do it
  49.  
  50.     mov    ax,cx            ; get year
  51.     mov    cl,100            ; we just want the sub-hundreds
  52.     div    cl
  53.     mov    al,ah            ; get fractional centuries
  54.     mov    si,offset year        ; get where we want it
  55.     call    form_dec_num        ; put AL into decimal format
  56.  
  57.     mov    al,dh            ; get month
  58.     mov    si,offset month     ; where it goes
  59.     call    form_dec_num
  60.  
  61.     mov    al,dl            ; get day
  62.     mov    si,offset day        ; where it goes
  63.     call    form_dec_num
  64.  
  65.     mov    stkseg,ss        ; save stk info
  66.     mov    stkptr,sp
  67.  
  68.     mov    si,offset outlen    ; get addr of command
  69.     int    2eh            ; do the undocumented interrupt
  70.  
  71.     mov    ss,stkseg        ; recover our stack
  72.     mov    sp,stkseg
  73.  
  74.     mov    ax,04c00h        ; exit to DOS
  75.     int    21h
  76. main    endp
  77.  
  78. form_dec_num    proc    near
  79.     push    ax
  80.  
  81.     xor    ah,ah
  82.     aam
  83.     add    ax,03030h        ; make both of them ASCII
  84.     xchg    ah,al            ; reverse for storage
  85.     mov    [si],ax
  86.  
  87.     pop    ax
  88.     ret
  89. form_dec_num    endp
  90.  
  91. end_of_code    label    byte
  92.  
  93. cseg    ends
  94.  
  95.     end    main
  96.